<template>
  <div class="header_box">
    <div class="header">
      <img class="image" :src="getImageUrl('min.png')" @click="min" />
      <img class="image" :src="getImageUrl('max.png')" @click="max" />
      <img class="image" :src="getImageUrl('close.png')" @click="close" />
    </div>
  </div>
</template>
<script setup>
import { ipcRenderer } from "electron";
//最小化
let min = () => {
  ipcRenderer.send("window-min");
};

//最大化
let max = () => {
  ipcRenderer.send("window-max");
};

//关闭
let close = () => {
  //关闭
  ElMessageBox.confirm("当前操作会关闭此程序，是否继续?", {
    confirmButtonText: "是",
    cancelButtonText: "否",
    type: "warning",
  })
    .then(() => {
      ipcRenderer.send("window-close");
    })
    .catch(() => {});
};

let getImageUrl = (name) => {
  // 请注意，这不包括子目录中的文件
  return new URL(`/src/image/${name}`, import.meta.url).href;
};
</script>
<style scoped>
.header_box {
  background: #c8d6e5;
  -webkit-app-region: drag;
  border-bottom: 1px solid #3498db;
}
.header {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.3125rem 0;
}
.image {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  margin: 0 0.625rem;
  cursor: pointer;
  -webkit-app-region: none;
}
</style>
